package Scene

import (
	. "GameLogic/GameConfig"
)

type unitCreateFn func(*XmlUnit, string, int, *Scene) IUnit
type triggerCreateFn func(scene *Scene) ISceneTrigger

func init() {
	unitCreateFns = make(map[string]unitCreateFn)
}

//单位构造函数
var unitCreateFns map[string]unitCreateFn

//触发器构造函数
var curTriggerCreateFn triggerCreateFn

func RegisterUnit(unitType string, fn unitCreateFn) {
	unitCreateFns[unitType] = fn
}
func SetSceneTriggerCreateFn(fn triggerCreateFn) {
	curTriggerCreateFn = fn
}
func CreateUnit(xmlUnit *XmlUnit, uuid string, GamePlayerId int, scene *Scene) IUnit {
	return unitCreateFns[xmlUnit.Type](xmlUnit, uuid, GamePlayerId, scene)
}

func newSceneTrigger(scene *Scene) ISceneTrigger {
	return curTriggerCreateFn(scene)
}
